<template>
  <div>
    <el-col>
      <p style="font-size: 30px">设置</p>
      <el-form>
        <el-form-item label="绑定大区">
          <!--          <el-select placeholder="请选择" @change="updateServerBind" v-model="server">-->
          <!--            <el-option v-for="s in serverList" :key="s" :value="s" :label="s">-->
          <!--            </el-option>-->
          <!--          </el-select>-->

          <el-cascader placeholder="绑定区服" :options="server_name" v-model="value"
                       @change="updateServerBind"></el-cascader>
        </el-form-item>

        <el-form-item label="绑定家园">
          <el-select placeholder="请选择" @change="updateMapBind" v-model="map">
            <el-option v-for="s in mapList" :key="s" :value="s" :label="s">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>

      <el-col>
        <p>author:Sully</p>
        <p>version:1.0.2</p>
        <p>copyright 2023 sully(牛战士)</p>
        <img src="@/assets/sullly.jpg"/>
      </el-col>
    </el-col>

  </div>
</template>

<script>
import {MAP_NAME, SERVER_NAME, SERVER_NAME2} from "@/constant/constant";
import {ElMessage} from "element-plus";

export default {
  name: "SettingPage",
  data() {
    return {
      serverList: SERVER_NAME,
      server_name: SERVER_NAME2,
      mapList: MAP_NAME,
      map: '',
      value: []
    }
  },
  methods: {
    updateServerBind(val) {
      localStorage.setItem('server_select', val[1])
      localStorage.setItem('server_bind', val[0])
      ElMessage.success('绑定成功')
    },
    updateMapBind(val) {
      localStorage.setItem('map_select', val)
      ElMessage.success('绑定成功')
    }
  },
  mounted() {
    if (localStorage.getItem('server_select') !== null) {
      this.server = localStorage.getItem('server_select')
      this.value = [localStorage.getItem('server_bind'),localStorage.getItem('server_select')]
    }

    if (localStorage.getItem('map_select') !== null) {
      this.map = localStorage.getItem('map_select')
    }
  }
}
</script>

<style scoped>

</style>
